#ifndef _U_BROADCAST_UDP_H
#define _U_BROADCAST_UDP_H

#include "uBroadcast.h"

#ifndef UB_BROADCAST_UDP_PORT
#define UB_BROADCAST_UDP_PORT 54545
#endif

typedef struct _ub_UPD {
	int udpSocket;
	int port;
	char id[6];
} ub_UDP;

/**
 * Connect to uBroadcast. Pass any id (for example MAC address) and port.
 * @return socket file descriptor.
 */
ub_UDP * ub_udp_connect(const char id[6], int port);

/**
 * Disconnect from uBroadcast.
 * Close UDP socket.
 */
void ub_udp_disconnect(ub_UDP * conn);

/**
 * Send message to uBroadcast
 */
void ub_udp_send(ub_UDP * conn, uMessage * msg);

/**
 * Wait for message from uBroadcast.
 * This method is blocking.
 * @return negative on error, any positive else.
 */
int ub_udp_recv(ub_UDP * conn, uMessage * msg);

#endif
